import heapq
class Solution(object):
    def halveArray(self, nums):
        t = sum(nums)
        target = t / 2
        nums = [-num for num in nums]
        heapq.heapify(nums)
        ans = 0
        count = 0
        while ans < target:
            count += 1
            node = heapq.heappop(nums)
            ans -= node / 2
            heapq.heappush(nums, node / 2)
        return count